﻿Public Class CellEditor : Inherits UserControl

	Public WithEvents EditBox As EditBox
	Dim Sheet As Sheet

	Sub New(Sheet As Sheet)
		Me.Sheet = Sheet
		DoubleBuffered = True
		ResizeRedraw = True
		EditBox = New EditBox(Sheet)
		Height = EditBox.Height + 2
		BackColor = MainColor
		Controls.Add(EditBox)
		EditBox.Location = New Point(27, 2)
		EditBox.Size = New Point(Width - EditBox.Left - 7, EditBox.Height)
		EditBox.Anchor = AnchorStyles.Left + AnchorStyles.Right
	End Sub

	Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
		MyBase.OnPaint(e)
		Dim R = EditBox.Bounds
		R.Inflate(4, 2)
		e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
		e.Graphics.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
		e.Graphics.FillRoundRect(Color.White.Brush, R, 3)
		R.Offset(-R.Left, 0)
		e.Graphics.FillRoundRect(Color.White.Opacity(80).Brush, R, 3, 1, 1, 3)
		R = New Rectangle(3, 2, 16, 16)
		e.Graphics.DrawImage(My.Resources.fx, R)
	End Sub

	Sub SetValue(Text As String)
		EditBox.SetValue(Text)
	End Sub

End Class
